--[[ 编码: JX-108-01 名称: 巨星任务-创建后 作者:HAN 日期:2025-1-29 级别:项目 函数: AfterDataObjCreate 功能: -- 判断容器号是否存在,存在要验证一下容器的类型是否=2(容器类型)不能是料格类型,否则会和料箱混了 -- 不存在创建一个容器对象 更改记录: --]] wms_cntr= require( "wms_container" ) wms_wh = require( "wms_wh" ) function AfterDataObjCreate ( strLuaDEID ) local nRet, strRetInfo local cntr, jx_task nRet, jx_task = m3.GetSysCurEditDataObj( strLuaDEID, "JX_Task" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..test ) end if ( jx_task.cntr_code ~= '' and jx_task.cntr_code ~= nil ) then nRet, cntr = wms_cntr.GetInfo (strLuaDEID, jx_task.cntr_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), cntr) end end if (jx_task.task_type == "入库" ) then if ( cntr == '' ) then -- 创建容器对象 local new_cntr = m3.AllocObject(strLuaDEID,"Container") new_cntr.code = jx_task.cntr_code new_cntr.type = 2 -- 容器类型 new_cntr.source = "" nRet, new_cntr = m3.CreateDataObj( strLuaDEID, new_cntr ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "创建容器失败!") end else if ( cntr.type == 3 ) then lua.Error( strLuaDEID, debug.getinfo(1), "容器编码'"..jx_task.cntr_code.."'的类型不能是料格类型!" ) end end elseif (jx_task.task_type == "出库" ) then if ( cntr == '' ) then mobox.stopProgram( strLuaDEID, "容器编码为'"..jx_task.cntr_code.."'的容器不存在!" ) return end if ( cntr.type == 3 ) then mobox.stopProgram( strLuaDEID, "容器编码为'"..jx_task.cntr_code.."'的容器类型不能是料格类型!" ) return end -- 检查一下容器的货位 local loc_code = wms_wh.GetLocCodeByCNTR( strLuaDEID, jx_task.cntr_code ) if ( loc_code == '' ) then mobox.stopProgram( strLuaDEID, "容器编码为'"..jx_task.cntr_code.."'的容器不在料箱库!" ) return end -- 更新任务的起点 local loc nRet, loc = wms_wh.GetLocInfo( loc_code ) if ( nRet ~= 0 ) then mobox.stopProgram( strLuaDEID, "容器编码为'"..jx_task.cntr_code.."'的容器货位编码'"..loc_code.."'不正确!" ) return end local strUpdateSql = "S_START_WH = '"..loc.wh_code.."', S_START_AREA = '"..loc.area_code.."', S_START_LOC = '"..loc.code.."'" local strCondition = "S_SOURNO = '"..jx_task.sour_no.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) end end end